TRUNCATE TABLE BTM_TEST_TSFHEAD;
TRUNCATE TABLE BTM_TEST_TSFDETAIL;
TRUNCATE TABLE BTM_TEST_ALLOC_HEADER;
TRUNCATE TABLE BTM_TEST_ALLOC_DETAIL;
TRUNCATE TABLE BTM_TEST_SHIPMENT;
TRUNCATE TABLE BTM_TEST_SHIPSKU;
TRUNCATE TABLE BTM_TEST_ITEM_LOC_SOH;
TRUNCATE TABLE BTM_TEST_INV_STATUS_QTY;
TRUNCATE TABLE BTM_TEST_TSF_XFORM_DETAIL;
TRUNCATE TABLE BTM_TEST_TSF_ITEM_COST;
TRUNCATE TABLE BTM_TEST_TRAN_DATA_A;
TRUNCATE TABLE BTM_TEST_ITEM_LOC_HIST;
TRUNCATE TABLE BTM_TEST_ITEM_LOC;
TRUNCATE TABLE BTM_TEST_PRICE_HIST;
TRUNCATE TABLE BTM_TEST_SHIPITEM_INV_FLOW;
DROP TRIGGER BTM_TEST_TSFHEAD_TRG;
DROP TRIGGER BTM_TEST_TSFDETAIL_TRG;
DROP TRIGGER BTM_TEST_ALLOC_HEADER_TRG;
DROP TRIGGER BTM_TEST_ALLOC_DETAIL_TRG;
DROP TRIGGER BTM_TEST_SHIPMENT_TRG;
DROP TRIGGER BTM_TEST_SHIPSKU_TRG;
DROP TRIGGER BTM_TEST_ITEM_LOC_SOH_TRG;
DROP TRIGGER BTM_TEST_INV_STATUS_QTY_TRG;
DROP TRIGGER BTM_TEST_TSF_XFORM_DETAIL_TRG;
DROP TRIGGER BTM_TEST_TSF_ITEM_COST_TRG;
DROP TRIGGER BTM_TEST_TRAN_DATA_A_TRG;
DROP TRIGGER BTM_TEST_ITEM_LOC_HIST_TRG;
DROP TRIGGER BTM_TEST_ITEM_LOC_TRG;
DROP TRIGGER BTM_TEST_PRICE_HIST_TRG;
DROP TRIGGER BTM_TEST_SHIPITEM_INV_FLOW_TRG;
DROP TABLE BTM_TEST_TSFHEAD;
DROP TABLE BTM_TEST_TSFDETAIL;
DROP TABLE BTM_TEST_ALLOC_HEADER;
DROP TABLE BTM_TEST_ALLOC_DETAIL;
DROP TABLE BTM_TEST_SHIPMENT;
DROP TABLE BTM_TEST_SHIPSKU;
DROP TABLE BTM_TEST_ITEM_LOC_SOH;
DROP TABLE BTM_TEST_INV_STATUS_QTY;
DROP TABLE BTM_TEST_TSF_XFORM_DETAIL;
DROP TABLE BTM_TEST_TSF_ITEM_COST;
DROP TABLE BTM_TEST_TRAN_DATA_A;
DROP TABLE BTM_TEST_ITEM_LOC_HIST;
DROP TABLE BTM_TEST_ITEM_LOC;
DROP TABLE BTM_TEST_PRICE_HIST;
DROP TABLE BTM_TEST_SHIPITEM_INV_FLOW;
-- TB_TSFHEAD
CREATE TABLE BTM_TEST_TSFHEAD AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM TSFHEAD TBS WHERE 1=0;
ALTER TABLE BTM_TEST_TSFHEAD  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_TSFHEAD_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON TSFHEAD
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_TSFHEAD(LOG_MG, WF_NEED_DATE, DELIVERY_SLOT_ID, ORDER_NO, TSF_NO, TSF_PARENT_NO, FROM_LOC_TYPE, FROM_LOC, TO_LOC_TYPE, TO_LOC, EXP_DC_DATE, DEPT, INVENTORY_TYPE, TSF_TYPE, STATUS, FREIGHT_CODE, ROUTING_CODE, CREATE_DATE, CREATE_ID, APPROVAL_DATE, APPROVAL_ID, DELIVERY_DATE, CLOSE_DATE, EXT_REF_NO, REPL_TSF_APPROVE_IND, COMMENT_DESC, EXP_DC_EOW_DATE, MRT_NO, NOT_AFTER_DATE, CONTEXT_TYPE, CONTEXT_VALUE, RESTOCK_PCT)
			values(LOG_MG || 'NEW', :new.WF_NEED_DATE, :new.DELIVERY_SLOT_ID, :new.ORDER_NO, :new.TSF_NO, :new.TSF_PARENT_NO, :new.FROM_LOC_TYPE, :new.FROM_LOC, :new.TO_LOC_TYPE, :new.TO_LOC, :new.EXP_DC_DATE, :new.DEPT, :new.INVENTORY_TYPE, :new.TSF_TYPE, :new.STATUS, :new.FREIGHT_CODE, :new.ROUTING_CODE, :new.CREATE_DATE, :new.CREATE_ID, :new.APPROVAL_DATE, :new.APPROVAL_ID, :new.DELIVERY_DATE, :new.CLOSE_DATE, :new.EXT_REF_NO, :new.REPL_TSF_APPROVE_IND, :new.COMMENT_DESC, :new.EXP_DC_EOW_DATE, :new.MRT_NO, :new.NOT_AFTER_DATE, :new.CONTEXT_TYPE, :new.CONTEXT_VALUE, :new.RESTOCK_PCT);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSFHEAD(LOG_MG, WF_NEED_DATE, DELIVERY_SLOT_ID, ORDER_NO, TSF_NO, TSF_PARENT_NO, FROM_LOC_TYPE, FROM_LOC, TO_LOC_TYPE, TO_LOC, EXP_DC_DATE, DEPT, INVENTORY_TYPE, TSF_TYPE, STATUS, FREIGHT_CODE, ROUTING_CODE, CREATE_DATE, CREATE_ID, APPROVAL_DATE, APPROVAL_ID, DELIVERY_DATE, CLOSE_DATE, EXT_REF_NO, REPL_TSF_APPROVE_IND, COMMENT_DESC, EXP_DC_EOW_DATE, MRT_NO, NOT_AFTER_DATE, CONTEXT_TYPE, CONTEXT_VALUE, RESTOCK_PCT)
			values(LOG_MG || 'OLD', :old.WF_NEED_DATE, :old.DELIVERY_SLOT_ID, :old.ORDER_NO, :old.TSF_NO, :old.TSF_PARENT_NO, :old.FROM_LOC_TYPE, :old.FROM_LOC, :old.TO_LOC_TYPE, :old.TO_LOC, :old.EXP_DC_DATE, :old.DEPT, :old.INVENTORY_TYPE, :old.TSF_TYPE, :old.STATUS, :old.FREIGHT_CODE, :old.ROUTING_CODE, :old.CREATE_DATE, :old.CREATE_ID, :old.APPROVAL_DATE, :old.APPROVAL_ID, :old.DELIVERY_DATE, :old.CLOSE_DATE, :old.EXT_REF_NO, :old.REPL_TSF_APPROVE_IND, :old.COMMENT_DESC, :old.EXP_DC_EOW_DATE, :old.MRT_NO, :old.NOT_AFTER_DATE, :old.CONTEXT_TYPE, :old.CONTEXT_VALUE, :old.RESTOCK_PCT);
		-- insert new
		INSERT INTO BTM_TEST_TSFHEAD(LOG_MG, WF_NEED_DATE, DELIVERY_SLOT_ID, ORDER_NO, TSF_NO, TSF_PARENT_NO, FROM_LOC_TYPE, FROM_LOC, TO_LOC_TYPE, TO_LOC, EXP_DC_DATE, DEPT, INVENTORY_TYPE, TSF_TYPE, STATUS, FREIGHT_CODE, ROUTING_CODE, CREATE_DATE, CREATE_ID, APPROVAL_DATE, APPROVAL_ID, DELIVERY_DATE, CLOSE_DATE, EXT_REF_NO, REPL_TSF_APPROVE_IND, COMMENT_DESC, EXP_DC_EOW_DATE, MRT_NO, NOT_AFTER_DATE, CONTEXT_TYPE, CONTEXT_VALUE, RESTOCK_PCT)
			values(LOG_MG || 'NEW', :new.WF_NEED_DATE, :new.DELIVERY_SLOT_ID, :new.ORDER_NO, :new.TSF_NO, :new.TSF_PARENT_NO, :new.FROM_LOC_TYPE, :new.FROM_LOC, :new.TO_LOC_TYPE, :new.TO_LOC, :new.EXP_DC_DATE, :new.DEPT, :new.INVENTORY_TYPE, :new.TSF_TYPE, :new.STATUS, :new.FREIGHT_CODE, :new.ROUTING_CODE, :new.CREATE_DATE, :new.CREATE_ID, :new.APPROVAL_DATE, :new.APPROVAL_ID, :new.DELIVERY_DATE, :new.CLOSE_DATE, :new.EXT_REF_NO, :new.REPL_TSF_APPROVE_IND, :new.COMMENT_DESC, :new.EXP_DC_EOW_DATE, :new.MRT_NO, :new.NOT_AFTER_DATE, :new.CONTEXT_TYPE, :new.CONTEXT_VALUE, :new.RESTOCK_PCT);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSFHEAD(LOG_MG, WF_NEED_DATE, DELIVERY_SLOT_ID, ORDER_NO, TSF_NO, TSF_PARENT_NO, FROM_LOC_TYPE, FROM_LOC, TO_LOC_TYPE, TO_LOC, EXP_DC_DATE, DEPT, INVENTORY_TYPE, TSF_TYPE, STATUS, FREIGHT_CODE, ROUTING_CODE, CREATE_DATE, CREATE_ID, APPROVAL_DATE, APPROVAL_ID, DELIVERY_DATE, CLOSE_DATE, EXT_REF_NO, REPL_TSF_APPROVE_IND, COMMENT_DESC, EXP_DC_EOW_DATE, MRT_NO, NOT_AFTER_DATE, CONTEXT_TYPE, CONTEXT_VALUE, RESTOCK_PCT)
			values(LOG_MG || 'OLD', :old.WF_NEED_DATE, :old.DELIVERY_SLOT_ID, :old.ORDER_NO, :old.TSF_NO, :old.TSF_PARENT_NO, :old.FROM_LOC_TYPE, :old.FROM_LOC, :old.TO_LOC_TYPE, :old.TO_LOC, :old.EXP_DC_DATE, :old.DEPT, :old.INVENTORY_TYPE, :old.TSF_TYPE, :old.STATUS, :old.FREIGHT_CODE, :old.ROUTING_CODE, :old.CREATE_DATE, :old.CREATE_ID, :old.APPROVAL_DATE, :old.APPROVAL_ID, :old.DELIVERY_DATE, :old.CLOSE_DATE, :old.EXT_REF_NO, :old.REPL_TSF_APPROVE_IND, :old.COMMENT_DESC, :old.EXP_DC_EOW_DATE, :old.MRT_NO, :old.NOT_AFTER_DATE, :old.CONTEXT_TYPE, :old.CONTEXT_VALUE, :old.RESTOCK_PCT);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_TSFHEAD_TRG ENABLE;
-- Next
-- TB_TSFDETAIL
CREATE TABLE BTM_TEST_TSFDETAIL AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM TSFDETAIL TBS WHERE 1=0;
ALTER TABLE BTM_TEST_TSFDETAIL  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_TSFDETAIL_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON TSFDETAIL
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_TSFDETAIL(LOG_MG, TSF_NO, TSF_SEQ_NO, ITEM, INV_STATUS, TSF_PRICE, TSF_QTY, FILL_QTY, SHIP_QTY, RECEIVED_QTY, RECONCILED_QTY, DISTRO_QTY, SELECTED_QTY, CANCELLED_QTY, SUPP_PACK_SIZE, TSF_PO_LINK_NO, DEFAULT_CHRGS_2_LEG_IND, MBR_PROCESSED_IND, PUBLISH_IND, TSF_COST, RESTOCK_PCT, FINISHER_AV_RETAIL, FINISHER_UNITS, UPDATED_BY_RMS_IND)
			values(LOG_MG || 'NEW', :new.TSF_NO, :new.TSF_SEQ_NO, :new.ITEM, :new.INV_STATUS, :new.TSF_PRICE, :new.TSF_QTY, :new.FILL_QTY, :new.SHIP_QTY, :new.RECEIVED_QTY, :new.RECONCILED_QTY, :new.DISTRO_QTY, :new.SELECTED_QTY, :new.CANCELLED_QTY, :new.SUPP_PACK_SIZE, :new.TSF_PO_LINK_NO, :new.DEFAULT_CHRGS_2_LEG_IND, :new.MBR_PROCESSED_IND, :new.PUBLISH_IND, :new.TSF_COST, :new.RESTOCK_PCT, :new.FINISHER_AV_RETAIL, :new.FINISHER_UNITS, :new.UPDATED_BY_RMS_IND);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSFDETAIL(LOG_MG, TSF_NO, TSF_SEQ_NO, ITEM, INV_STATUS, TSF_PRICE, TSF_QTY, FILL_QTY, SHIP_QTY, RECEIVED_QTY, RECONCILED_QTY, DISTRO_QTY, SELECTED_QTY, CANCELLED_QTY, SUPP_PACK_SIZE, TSF_PO_LINK_NO, DEFAULT_CHRGS_2_LEG_IND, MBR_PROCESSED_IND, PUBLISH_IND, TSF_COST, RESTOCK_PCT, FINISHER_AV_RETAIL, FINISHER_UNITS, UPDATED_BY_RMS_IND)
			values(LOG_MG || 'OLD', :old.TSF_NO, :old.TSF_SEQ_NO, :old.ITEM, :old.INV_STATUS, :old.TSF_PRICE, :old.TSF_QTY, :old.FILL_QTY, :old.SHIP_QTY, :old.RECEIVED_QTY, :old.RECONCILED_QTY, :old.DISTRO_QTY, :old.SELECTED_QTY, :old.CANCELLED_QTY, :old.SUPP_PACK_SIZE, :old.TSF_PO_LINK_NO, :old.DEFAULT_CHRGS_2_LEG_IND, :old.MBR_PROCESSED_IND, :old.PUBLISH_IND, :old.TSF_COST, :old.RESTOCK_PCT, :old.FINISHER_AV_RETAIL, :old.FINISHER_UNITS, :old.UPDATED_BY_RMS_IND);
		-- insert new
		INSERT INTO BTM_TEST_TSFDETAIL(LOG_MG, TSF_NO, TSF_SEQ_NO, ITEM, INV_STATUS, TSF_PRICE, TSF_QTY, FILL_QTY, SHIP_QTY, RECEIVED_QTY, RECONCILED_QTY, DISTRO_QTY, SELECTED_QTY, CANCELLED_QTY, SUPP_PACK_SIZE, TSF_PO_LINK_NO, DEFAULT_CHRGS_2_LEG_IND, MBR_PROCESSED_IND, PUBLISH_IND, TSF_COST, RESTOCK_PCT, FINISHER_AV_RETAIL, FINISHER_UNITS, UPDATED_BY_RMS_IND)
			values(LOG_MG || 'NEW', :new.TSF_NO, :new.TSF_SEQ_NO, :new.ITEM, :new.INV_STATUS, :new.TSF_PRICE, :new.TSF_QTY, :new.FILL_QTY, :new.SHIP_QTY, :new.RECEIVED_QTY, :new.RECONCILED_QTY, :new.DISTRO_QTY, :new.SELECTED_QTY, :new.CANCELLED_QTY, :new.SUPP_PACK_SIZE, :new.TSF_PO_LINK_NO, :new.DEFAULT_CHRGS_2_LEG_IND, :new.MBR_PROCESSED_IND, :new.PUBLISH_IND, :new.TSF_COST, :new.RESTOCK_PCT, :new.FINISHER_AV_RETAIL, :new.FINISHER_UNITS, :new.UPDATED_BY_RMS_IND);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSFDETAIL(LOG_MG, TSF_NO, TSF_SEQ_NO, ITEM, INV_STATUS, TSF_PRICE, TSF_QTY, FILL_QTY, SHIP_QTY, RECEIVED_QTY, RECONCILED_QTY, DISTRO_QTY, SELECTED_QTY, CANCELLED_QTY, SUPP_PACK_SIZE, TSF_PO_LINK_NO, DEFAULT_CHRGS_2_LEG_IND, MBR_PROCESSED_IND, PUBLISH_IND, TSF_COST, RESTOCK_PCT, FINISHER_AV_RETAIL, FINISHER_UNITS, UPDATED_BY_RMS_IND)
			values(LOG_MG || 'OLD', :old.TSF_NO, :old.TSF_SEQ_NO, :old.ITEM, :old.INV_STATUS, :old.TSF_PRICE, :old.TSF_QTY, :old.FILL_QTY, :old.SHIP_QTY, :old.RECEIVED_QTY, :old.RECONCILED_QTY, :old.DISTRO_QTY, :old.SELECTED_QTY, :old.CANCELLED_QTY, :old.SUPP_PACK_SIZE, :old.TSF_PO_LINK_NO, :old.DEFAULT_CHRGS_2_LEG_IND, :old.MBR_PROCESSED_IND, :old.PUBLISH_IND, :old.TSF_COST, :old.RESTOCK_PCT, :old.FINISHER_AV_RETAIL, :old.FINISHER_UNITS, :old.UPDATED_BY_RMS_IND);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_TSFDETAIL_TRG ENABLE;
-- Next
-- TB_ALLOC_HEADER
CREATE TABLE BTM_TEST_ALLOC_HEADER AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM ALLOC_HEADER TBS WHERE 1=0;
ALTER TABLE BTM_TEST_ALLOC_HEADER  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_ALLOC_HEADER_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON ALLOC_HEADER
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_ALLOC_HEADER(LOG_MG, ALLOC_NO, ORDER_NO, WH, ITEM, STATUS, ALLOC_DESC, PO_TYPE, ALLOC_METHOD, RELEASE_DATE, ORDER_TYPE, CONTEXT_TYPE, CONTEXT_VALUE, COMMENT_DESC, DOC, DOC_TYPE, ALLOC_PARENT)
			values(LOG_MG || 'NEW', :new.ALLOC_NO, :new.ORDER_NO, :new.WH, :new.ITEM, :new.STATUS, :new.ALLOC_DESC, :new.PO_TYPE, :new.ALLOC_METHOD, :new.RELEASE_DATE, :new.ORDER_TYPE, :new.CONTEXT_TYPE, :new.CONTEXT_VALUE, :new.COMMENT_DESC, :new.DOC, :new.DOC_TYPE, :new.ALLOC_PARENT);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ALLOC_HEADER(LOG_MG, ALLOC_NO, ORDER_NO, WH, ITEM, STATUS, ALLOC_DESC, PO_TYPE, ALLOC_METHOD, RELEASE_DATE, ORDER_TYPE, CONTEXT_TYPE, CONTEXT_VALUE, COMMENT_DESC, DOC, DOC_TYPE, ALLOC_PARENT)
			values(LOG_MG || 'OLD', :old.ALLOC_NO, :old.ORDER_NO, :old.WH, :old.ITEM, :old.STATUS, :old.ALLOC_DESC, :old.PO_TYPE, :old.ALLOC_METHOD, :old.RELEASE_DATE, :old.ORDER_TYPE, :old.CONTEXT_TYPE, :old.CONTEXT_VALUE, :old.COMMENT_DESC, :old.DOC, :old.DOC_TYPE, :old.ALLOC_PARENT);
		-- insert new
		INSERT INTO BTM_TEST_ALLOC_HEADER(LOG_MG, ALLOC_NO, ORDER_NO, WH, ITEM, STATUS, ALLOC_DESC, PO_TYPE, ALLOC_METHOD, RELEASE_DATE, ORDER_TYPE, CONTEXT_TYPE, CONTEXT_VALUE, COMMENT_DESC, DOC, DOC_TYPE, ALLOC_PARENT)
			values(LOG_MG || 'NEW', :new.ALLOC_NO, :new.ORDER_NO, :new.WH, :new.ITEM, :new.STATUS, :new.ALLOC_DESC, :new.PO_TYPE, :new.ALLOC_METHOD, :new.RELEASE_DATE, :new.ORDER_TYPE, :new.CONTEXT_TYPE, :new.CONTEXT_VALUE, :new.COMMENT_DESC, :new.DOC, :new.DOC_TYPE, :new.ALLOC_PARENT);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ALLOC_HEADER(LOG_MG, ALLOC_NO, ORDER_NO, WH, ITEM, STATUS, ALLOC_DESC, PO_TYPE, ALLOC_METHOD, RELEASE_DATE, ORDER_TYPE, CONTEXT_TYPE, CONTEXT_VALUE, COMMENT_DESC, DOC, DOC_TYPE, ALLOC_PARENT)
			values(LOG_MG || 'OLD', :old.ALLOC_NO, :old.ORDER_NO, :old.WH, :old.ITEM, :old.STATUS, :old.ALLOC_DESC, :old.PO_TYPE, :old.ALLOC_METHOD, :old.RELEASE_DATE, :old.ORDER_TYPE, :old.CONTEXT_TYPE, :old.CONTEXT_VALUE, :old.COMMENT_DESC, :old.DOC, :old.DOC_TYPE, :old.ALLOC_PARENT);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_ALLOC_HEADER_TRG ENABLE;
-- Next
-- TB_ALLOC_DETAIL
CREATE TABLE BTM_TEST_ALLOC_DETAIL AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM ALLOC_DETAIL TBS WHERE 1=0;
ALTER TABLE BTM_TEST_ALLOC_DETAIL  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_ALLOC_DETAIL_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON ALLOC_DETAIL
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_ALLOC_DETAIL(LOG_MG, ALLOC_NO, TO_LOC, TO_LOC_TYPE, QTY_TRANSFERRED, QTY_ALLOCATED, QTY_PRESCALED, QTY_DISTRO, QTY_SELECTED, QTY_CANCELLED, QTY_RECEIVED, QTY_RECONCILED, PO_RCVD_QTY, NON_SCALE_IND, IN_STORE_DATE, RUSH_FLAG)
			values(LOG_MG || 'NEW', :new.ALLOC_NO, :new.TO_LOC, :new.TO_LOC_TYPE, :new.QTY_TRANSFERRED, :new.QTY_ALLOCATED, :new.QTY_PRESCALED, :new.QTY_DISTRO, :new.QTY_SELECTED, :new.QTY_CANCELLED, :new.QTY_RECEIVED, :new.QTY_RECONCILED, :new.PO_RCVD_QTY, :new.NON_SCALE_IND, :new.IN_STORE_DATE, :new.RUSH_FLAG);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ALLOC_DETAIL(LOG_MG, ALLOC_NO, TO_LOC, TO_LOC_TYPE, QTY_TRANSFERRED, QTY_ALLOCATED, QTY_PRESCALED, QTY_DISTRO, QTY_SELECTED, QTY_CANCELLED, QTY_RECEIVED, QTY_RECONCILED, PO_RCVD_QTY, NON_SCALE_IND, IN_STORE_DATE, RUSH_FLAG)
			values(LOG_MG || 'OLD', :old.ALLOC_NO, :old.TO_LOC, :old.TO_LOC_TYPE, :old.QTY_TRANSFERRED, :old.QTY_ALLOCATED, :old.QTY_PRESCALED, :old.QTY_DISTRO, :old.QTY_SELECTED, :old.QTY_CANCELLED, :old.QTY_RECEIVED, :old.QTY_RECONCILED, :old.PO_RCVD_QTY, :old.NON_SCALE_IND, :old.IN_STORE_DATE, :old.RUSH_FLAG);
		-- insert new
		INSERT INTO BTM_TEST_ALLOC_DETAIL(LOG_MG, ALLOC_NO, TO_LOC, TO_LOC_TYPE, QTY_TRANSFERRED, QTY_ALLOCATED, QTY_PRESCALED, QTY_DISTRO, QTY_SELECTED, QTY_CANCELLED, QTY_RECEIVED, QTY_RECONCILED, PO_RCVD_QTY, NON_SCALE_IND, IN_STORE_DATE, RUSH_FLAG)
			values(LOG_MG || 'NEW', :new.ALLOC_NO, :new.TO_LOC, :new.TO_LOC_TYPE, :new.QTY_TRANSFERRED, :new.QTY_ALLOCATED, :new.QTY_PRESCALED, :new.QTY_DISTRO, :new.QTY_SELECTED, :new.QTY_CANCELLED, :new.QTY_RECEIVED, :new.QTY_RECONCILED, :new.PO_RCVD_QTY, :new.NON_SCALE_IND, :new.IN_STORE_DATE, :new.RUSH_FLAG);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ALLOC_DETAIL(LOG_MG, ALLOC_NO, TO_LOC, TO_LOC_TYPE, QTY_TRANSFERRED, QTY_ALLOCATED, QTY_PRESCALED, QTY_DISTRO, QTY_SELECTED, QTY_CANCELLED, QTY_RECEIVED, QTY_RECONCILED, PO_RCVD_QTY, NON_SCALE_IND, IN_STORE_DATE, RUSH_FLAG)
			values(LOG_MG || 'OLD', :old.ALLOC_NO, :old.TO_LOC, :old.TO_LOC_TYPE, :old.QTY_TRANSFERRED, :old.QTY_ALLOCATED, :old.QTY_PRESCALED, :old.QTY_DISTRO, :old.QTY_SELECTED, :old.QTY_CANCELLED, :old.QTY_RECEIVED, :old.QTY_RECONCILED, :old.PO_RCVD_QTY, :old.NON_SCALE_IND, :old.IN_STORE_DATE, :old.RUSH_FLAG);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_ALLOC_DETAIL_TRG ENABLE;
-- Next
-- TB_SHIPMENT
CREATE TABLE BTM_TEST_SHIPMENT AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM SHIPMENT TBS WHERE 1=0;
ALTER TABLE BTM_TEST_SHIPMENT  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_SHIPMENT_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON SHIPMENT
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_SHIPMENT(LOG_MG, REF_DOC_NO, BILL_TO_LOC, BILL_TO_LOC_TYPE, SHIPMENT, ORDER_NO, BOL_NO, ASN, SHIP_DATE, RECEIVE_DATE, EST_ARR_DATE, SHIP_ORIGIN, STATUS_CODE, INVC_MATCH_STATUS, INVC_MATCH_DATE, TO_LOC, TO_LOC_TYPE, FROM_LOC, FROM_LOC_TYPE, COURIER, NO_BOXES, EXT_REF_NO_IN, EXT_REF_NO_OUT, COMMENTS, PARENT_SHIPMENT)
			values(LOG_MG || 'NEW', :new.REF_DOC_NO, :new.BILL_TO_LOC, :new.BILL_TO_LOC_TYPE, :new.SHIPMENT, :new.ORDER_NO, :new.BOL_NO, :new.ASN, :new.SHIP_DATE, :new.RECEIVE_DATE, :new.EST_ARR_DATE, :new.SHIP_ORIGIN, :new.STATUS_CODE, :new.INVC_MATCH_STATUS, :new.INVC_MATCH_DATE, :new.TO_LOC, :new.TO_LOC_TYPE, :new.FROM_LOC, :new.FROM_LOC_TYPE, :new.COURIER, :new.NO_BOXES, :new.EXT_REF_NO_IN, :new.EXT_REF_NO_OUT, :new.COMMENTS, :new.PARENT_SHIPMENT);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_SHIPMENT(LOG_MG, REF_DOC_NO, BILL_TO_LOC, BILL_TO_LOC_TYPE, SHIPMENT, ORDER_NO, BOL_NO, ASN, SHIP_DATE, RECEIVE_DATE, EST_ARR_DATE, SHIP_ORIGIN, STATUS_CODE, INVC_MATCH_STATUS, INVC_MATCH_DATE, TO_LOC, TO_LOC_TYPE, FROM_LOC, FROM_LOC_TYPE, COURIER, NO_BOXES, EXT_REF_NO_IN, EXT_REF_NO_OUT, COMMENTS, PARENT_SHIPMENT)
			values(LOG_MG || 'OLD', :old.REF_DOC_NO, :old.BILL_TO_LOC, :old.BILL_TO_LOC_TYPE, :old.SHIPMENT, :old.ORDER_NO, :old.BOL_NO, :old.ASN, :old.SHIP_DATE, :old.RECEIVE_DATE, :old.EST_ARR_DATE, :old.SHIP_ORIGIN, :old.STATUS_CODE, :old.INVC_MATCH_STATUS, :old.INVC_MATCH_DATE, :old.TO_LOC, :old.TO_LOC_TYPE, :old.FROM_LOC, :old.FROM_LOC_TYPE, :old.COURIER, :old.NO_BOXES, :old.EXT_REF_NO_IN, :old.EXT_REF_NO_OUT, :old.COMMENTS, :old.PARENT_SHIPMENT);
		-- insert new
		INSERT INTO BTM_TEST_SHIPMENT(LOG_MG, REF_DOC_NO, BILL_TO_LOC, BILL_TO_LOC_TYPE, SHIPMENT, ORDER_NO, BOL_NO, ASN, SHIP_DATE, RECEIVE_DATE, EST_ARR_DATE, SHIP_ORIGIN, STATUS_CODE, INVC_MATCH_STATUS, INVC_MATCH_DATE, TO_LOC, TO_LOC_TYPE, FROM_LOC, FROM_LOC_TYPE, COURIER, NO_BOXES, EXT_REF_NO_IN, EXT_REF_NO_OUT, COMMENTS, PARENT_SHIPMENT)
			values(LOG_MG || 'NEW', :new.REF_DOC_NO, :new.BILL_TO_LOC, :new.BILL_TO_LOC_TYPE, :new.SHIPMENT, :new.ORDER_NO, :new.BOL_NO, :new.ASN, :new.SHIP_DATE, :new.RECEIVE_DATE, :new.EST_ARR_DATE, :new.SHIP_ORIGIN, :new.STATUS_CODE, :new.INVC_MATCH_STATUS, :new.INVC_MATCH_DATE, :new.TO_LOC, :new.TO_LOC_TYPE, :new.FROM_LOC, :new.FROM_LOC_TYPE, :new.COURIER, :new.NO_BOXES, :new.EXT_REF_NO_IN, :new.EXT_REF_NO_OUT, :new.COMMENTS, :new.PARENT_SHIPMENT);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_SHIPMENT(LOG_MG, REF_DOC_NO, BILL_TO_LOC, BILL_TO_LOC_TYPE, SHIPMENT, ORDER_NO, BOL_NO, ASN, SHIP_DATE, RECEIVE_DATE, EST_ARR_DATE, SHIP_ORIGIN, STATUS_CODE, INVC_MATCH_STATUS, INVC_MATCH_DATE, TO_LOC, TO_LOC_TYPE, FROM_LOC, FROM_LOC_TYPE, COURIER, NO_BOXES, EXT_REF_NO_IN, EXT_REF_NO_OUT, COMMENTS, PARENT_SHIPMENT)
			values(LOG_MG || 'OLD', :old.REF_DOC_NO, :old.BILL_TO_LOC, :old.BILL_TO_LOC_TYPE, :old.SHIPMENT, :old.ORDER_NO, :old.BOL_NO, :old.ASN, :old.SHIP_DATE, :old.RECEIVE_DATE, :old.EST_ARR_DATE, :old.SHIP_ORIGIN, :old.STATUS_CODE, :old.INVC_MATCH_STATUS, :old.INVC_MATCH_DATE, :old.TO_LOC, :old.TO_LOC_TYPE, :old.FROM_LOC, :old.FROM_LOC_TYPE, :old.COURIER, :old.NO_BOXES, :old.EXT_REF_NO_IN, :old.EXT_REF_NO_OUT, :old.COMMENTS, :old.PARENT_SHIPMENT);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_SHIPMENT_TRG ENABLE;
-- Next
-- TB_SHIPSKU
CREATE TABLE BTM_TEST_SHIPSKU AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM SHIPSKU TBS WHERE 1=0;
ALTER TABLE BTM_TEST_SHIPSKU  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_SHIPSKU_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON SHIPSKU
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_SHIPSKU(LOG_MG, SHIPMENT, SEQ_NO, ITEM, DISTRO_NO, DISTRO_TYPE, REF_ITEM, CARTON, INV_STATUS, STATUS_CODE, QTY_RECEIVED, UNIT_COST, UNIT_RETAIL, QTY_EXPECTED, MATCH_INVC_ID, ADJUST_TYPE, ACTUAL_RECEIVING_STORE, RECONCILE_USER_ID, RECONCILE_DATE, TAMPERED_IND, DISPOSITIONED_IND, QTY_MATCHED, WEIGHT_RECEIVED, WEIGHT_RECEIVED_UOM, WEIGHT_EXPECTED, WEIGHT_EXPECTED_UOM)
			values(LOG_MG || 'NEW', :new.SHIPMENT, :new.SEQ_NO, :new.ITEM, :new.DISTRO_NO, :new.DISTRO_TYPE, :new.REF_ITEM, :new.CARTON, :new.INV_STATUS, :new.STATUS_CODE, :new.QTY_RECEIVED, :new.UNIT_COST, :new.UNIT_RETAIL, :new.QTY_EXPECTED, :new.MATCH_INVC_ID, :new.ADJUST_TYPE, :new.ACTUAL_RECEIVING_STORE, :new.RECONCILE_USER_ID, :new.RECONCILE_DATE, :new.TAMPERED_IND, :new.DISPOSITIONED_IND, :new.QTY_MATCHED, :new.WEIGHT_RECEIVED, :new.WEIGHT_RECEIVED_UOM, :new.WEIGHT_EXPECTED, :new.WEIGHT_EXPECTED_UOM);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_SHIPSKU(LOG_MG, SHIPMENT, SEQ_NO, ITEM, DISTRO_NO, DISTRO_TYPE, REF_ITEM, CARTON, INV_STATUS, STATUS_CODE, QTY_RECEIVED, UNIT_COST, UNIT_RETAIL, QTY_EXPECTED, MATCH_INVC_ID, ADJUST_TYPE, ACTUAL_RECEIVING_STORE, RECONCILE_USER_ID, RECONCILE_DATE, TAMPERED_IND, DISPOSITIONED_IND, QTY_MATCHED, WEIGHT_RECEIVED, WEIGHT_RECEIVED_UOM, WEIGHT_EXPECTED, WEIGHT_EXPECTED_UOM)
			values(LOG_MG || 'OLD', :old.SHIPMENT, :old.SEQ_NO, :old.ITEM, :old.DISTRO_NO, :old.DISTRO_TYPE, :old.REF_ITEM, :old.CARTON, :old.INV_STATUS, :old.STATUS_CODE, :old.QTY_RECEIVED, :old.UNIT_COST, :old.UNIT_RETAIL, :old.QTY_EXPECTED, :old.MATCH_INVC_ID, :old.ADJUST_TYPE, :old.ACTUAL_RECEIVING_STORE, :old.RECONCILE_USER_ID, :old.RECONCILE_DATE, :old.TAMPERED_IND, :old.DISPOSITIONED_IND, :old.QTY_MATCHED, :old.WEIGHT_RECEIVED, :old.WEIGHT_RECEIVED_UOM, :old.WEIGHT_EXPECTED, :old.WEIGHT_EXPECTED_UOM);
		-- insert new
		INSERT INTO BTM_TEST_SHIPSKU(LOG_MG, SHIPMENT, SEQ_NO, ITEM, DISTRO_NO, DISTRO_TYPE, REF_ITEM, CARTON, INV_STATUS, STATUS_CODE, QTY_RECEIVED, UNIT_COST, UNIT_RETAIL, QTY_EXPECTED, MATCH_INVC_ID, ADJUST_TYPE, ACTUAL_RECEIVING_STORE, RECONCILE_USER_ID, RECONCILE_DATE, TAMPERED_IND, DISPOSITIONED_IND, QTY_MATCHED, WEIGHT_RECEIVED, WEIGHT_RECEIVED_UOM, WEIGHT_EXPECTED, WEIGHT_EXPECTED_UOM)
			values(LOG_MG || 'NEW', :new.SHIPMENT, :new.SEQ_NO, :new.ITEM, :new.DISTRO_NO, :new.DISTRO_TYPE, :new.REF_ITEM, :new.CARTON, :new.INV_STATUS, :new.STATUS_CODE, :new.QTY_RECEIVED, :new.UNIT_COST, :new.UNIT_RETAIL, :new.QTY_EXPECTED, :new.MATCH_INVC_ID, :new.ADJUST_TYPE, :new.ACTUAL_RECEIVING_STORE, :new.RECONCILE_USER_ID, :new.RECONCILE_DATE, :new.TAMPERED_IND, :new.DISPOSITIONED_IND, :new.QTY_MATCHED, :new.WEIGHT_RECEIVED, :new.WEIGHT_RECEIVED_UOM, :new.WEIGHT_EXPECTED, :new.WEIGHT_EXPECTED_UOM);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_SHIPSKU(LOG_MG, SHIPMENT, SEQ_NO, ITEM, DISTRO_NO, DISTRO_TYPE, REF_ITEM, CARTON, INV_STATUS, STATUS_CODE, QTY_RECEIVED, UNIT_COST, UNIT_RETAIL, QTY_EXPECTED, MATCH_INVC_ID, ADJUST_TYPE, ACTUAL_RECEIVING_STORE, RECONCILE_USER_ID, RECONCILE_DATE, TAMPERED_IND, DISPOSITIONED_IND, QTY_MATCHED, WEIGHT_RECEIVED, WEIGHT_RECEIVED_UOM, WEIGHT_EXPECTED, WEIGHT_EXPECTED_UOM)
			values(LOG_MG || 'OLD', :old.SHIPMENT, :old.SEQ_NO, :old.ITEM, :old.DISTRO_NO, :old.DISTRO_TYPE, :old.REF_ITEM, :old.CARTON, :old.INV_STATUS, :old.STATUS_CODE, :old.QTY_RECEIVED, :old.UNIT_COST, :old.UNIT_RETAIL, :old.QTY_EXPECTED, :old.MATCH_INVC_ID, :old.ADJUST_TYPE, :old.ACTUAL_RECEIVING_STORE, :old.RECONCILE_USER_ID, :old.RECONCILE_DATE, :old.TAMPERED_IND, :old.DISPOSITIONED_IND, :old.QTY_MATCHED, :old.WEIGHT_RECEIVED, :old.WEIGHT_RECEIVED_UOM, :old.WEIGHT_EXPECTED, :old.WEIGHT_EXPECTED_UOM);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_SHIPSKU_TRG ENABLE;
-- Next
-- TB_ITEM_LOC_SOH
CREATE TABLE BTM_TEST_ITEM_LOC_SOH AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM ITEM_LOC_SOH TBS WHERE 1=0;
ALTER TABLE BTM_TEST_ITEM_LOC_SOH  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_ITEM_LOC_SOH_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON ITEM_LOC_SOH
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_ITEM_LOC_SOH(LOG_MG, ITEM, ITEM_PARENT, ITEM_GRANDPARENT, LOC, LOC_TYPE, AV_COST, UNIT_COST, STOCK_ON_HAND, SOH_UPDATE_DATETIME, LAST_HIST_EXPORT_DATE, IN_TRANSIT_QTY, PACK_COMP_INTRAN, PACK_COMP_SOH, TSF_RESERVED_QTY, PACK_COMP_RESV, TSF_EXPECTED_QTY, PACK_COMP_EXP, RTV_QTY, NON_SELLABLE_QTY, CUSTOMER_RESV, CUSTOMER_BACKORDER, PACK_COMP_CUST_RESV, PACK_COMP_CUST_BACK, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, FIRST_RECEIVED, LAST_RECEIVED, QTY_RECEIVED, FIRST_SOLD, LAST_SOLD, QTY_SOLD, PRIMARY_SUPP, PRIMARY_CNTRY, AVERAGE_WEIGHT, FINISHER_AV_RETAIL, FINISHER_UNITS, PACK_COMP_NON_SELLABLE)
			values(LOG_MG || 'NEW', :new.ITEM, :new.ITEM_PARENT, :new.ITEM_GRANDPARENT, :new.LOC, :new.LOC_TYPE, :new.AV_COST, :new.UNIT_COST, :new.STOCK_ON_HAND, :new.SOH_UPDATE_DATETIME, :new.LAST_HIST_EXPORT_DATE, :new.IN_TRANSIT_QTY, :new.PACK_COMP_INTRAN, :new.PACK_COMP_SOH, :new.TSF_RESERVED_QTY, :new.PACK_COMP_RESV, :new.TSF_EXPECTED_QTY, :new.PACK_COMP_EXP, :new.RTV_QTY, :new.NON_SELLABLE_QTY, :new.CUSTOMER_RESV, :new.CUSTOMER_BACKORDER, :new.PACK_COMP_CUST_RESV, :new.PACK_COMP_CUST_BACK, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID, :new.FIRST_RECEIVED, :new.LAST_RECEIVED, :new.QTY_RECEIVED, :new.FIRST_SOLD, :new.LAST_SOLD, :new.QTY_SOLD, :new.PRIMARY_SUPP, :new.PRIMARY_CNTRY, :new.AVERAGE_WEIGHT, :new.FINISHER_AV_RETAIL, :new.FINISHER_UNITS, :new.PACK_COMP_NON_SELLABLE);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ITEM_LOC_SOH(LOG_MG, ITEM, ITEM_PARENT, ITEM_GRANDPARENT, LOC, LOC_TYPE, AV_COST, UNIT_COST, STOCK_ON_HAND, SOH_UPDATE_DATETIME, LAST_HIST_EXPORT_DATE, IN_TRANSIT_QTY, PACK_COMP_INTRAN, PACK_COMP_SOH, TSF_RESERVED_QTY, PACK_COMP_RESV, TSF_EXPECTED_QTY, PACK_COMP_EXP, RTV_QTY, NON_SELLABLE_QTY, CUSTOMER_RESV, CUSTOMER_BACKORDER, PACK_COMP_CUST_RESV, PACK_COMP_CUST_BACK, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, FIRST_RECEIVED, LAST_RECEIVED, QTY_RECEIVED, FIRST_SOLD, LAST_SOLD, QTY_SOLD, PRIMARY_SUPP, PRIMARY_CNTRY, AVERAGE_WEIGHT, FINISHER_AV_RETAIL, FINISHER_UNITS, PACK_COMP_NON_SELLABLE)
			values(LOG_MG || 'OLD', :old.ITEM, :old.ITEM_PARENT, :old.ITEM_GRANDPARENT, :old.LOC, :old.LOC_TYPE, :old.AV_COST, :old.UNIT_COST, :old.STOCK_ON_HAND, :old.SOH_UPDATE_DATETIME, :old.LAST_HIST_EXPORT_DATE, :old.IN_TRANSIT_QTY, :old.PACK_COMP_INTRAN, :old.PACK_COMP_SOH, :old.TSF_RESERVED_QTY, :old.PACK_COMP_RESV, :old.TSF_EXPECTED_QTY, :old.PACK_COMP_EXP, :old.RTV_QTY, :old.NON_SELLABLE_QTY, :old.CUSTOMER_RESV, :old.CUSTOMER_BACKORDER, :old.PACK_COMP_CUST_RESV, :old.PACK_COMP_CUST_BACK, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID, :old.FIRST_RECEIVED, :old.LAST_RECEIVED, :old.QTY_RECEIVED, :old.FIRST_SOLD, :old.LAST_SOLD, :old.QTY_SOLD, :old.PRIMARY_SUPP, :old.PRIMARY_CNTRY, :old.AVERAGE_WEIGHT, :old.FINISHER_AV_RETAIL, :old.FINISHER_UNITS, :old.PACK_COMP_NON_SELLABLE);
		-- insert new
		INSERT INTO BTM_TEST_ITEM_LOC_SOH(LOG_MG, ITEM, ITEM_PARENT, ITEM_GRANDPARENT, LOC, LOC_TYPE, AV_COST, UNIT_COST, STOCK_ON_HAND, SOH_UPDATE_DATETIME, LAST_HIST_EXPORT_DATE, IN_TRANSIT_QTY, PACK_COMP_INTRAN, PACK_COMP_SOH, TSF_RESERVED_QTY, PACK_COMP_RESV, TSF_EXPECTED_QTY, PACK_COMP_EXP, RTV_QTY, NON_SELLABLE_QTY, CUSTOMER_RESV, CUSTOMER_BACKORDER, PACK_COMP_CUST_RESV, PACK_COMP_CUST_BACK, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, FIRST_RECEIVED, LAST_RECEIVED, QTY_RECEIVED, FIRST_SOLD, LAST_SOLD, QTY_SOLD, PRIMARY_SUPP, PRIMARY_CNTRY, AVERAGE_WEIGHT, FINISHER_AV_RETAIL, FINISHER_UNITS, PACK_COMP_NON_SELLABLE)
			values(LOG_MG || 'NEW', :new.ITEM, :new.ITEM_PARENT, :new.ITEM_GRANDPARENT, :new.LOC, :new.LOC_TYPE, :new.AV_COST, :new.UNIT_COST, :new.STOCK_ON_HAND, :new.SOH_UPDATE_DATETIME, :new.LAST_HIST_EXPORT_DATE, :new.IN_TRANSIT_QTY, :new.PACK_COMP_INTRAN, :new.PACK_COMP_SOH, :new.TSF_RESERVED_QTY, :new.PACK_COMP_RESV, :new.TSF_EXPECTED_QTY, :new.PACK_COMP_EXP, :new.RTV_QTY, :new.NON_SELLABLE_QTY, :new.CUSTOMER_RESV, :new.CUSTOMER_BACKORDER, :new.PACK_COMP_CUST_RESV, :new.PACK_COMP_CUST_BACK, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID, :new.FIRST_RECEIVED, :new.LAST_RECEIVED, :new.QTY_RECEIVED, :new.FIRST_SOLD, :new.LAST_SOLD, :new.QTY_SOLD, :new.PRIMARY_SUPP, :new.PRIMARY_CNTRY, :new.AVERAGE_WEIGHT, :new.FINISHER_AV_RETAIL, :new.FINISHER_UNITS, :new.PACK_COMP_NON_SELLABLE);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ITEM_LOC_SOH(LOG_MG, ITEM, ITEM_PARENT, ITEM_GRANDPARENT, LOC, LOC_TYPE, AV_COST, UNIT_COST, STOCK_ON_HAND, SOH_UPDATE_DATETIME, LAST_HIST_EXPORT_DATE, IN_TRANSIT_QTY, PACK_COMP_INTRAN, PACK_COMP_SOH, TSF_RESERVED_QTY, PACK_COMP_RESV, TSF_EXPECTED_QTY, PACK_COMP_EXP, RTV_QTY, NON_SELLABLE_QTY, CUSTOMER_RESV, CUSTOMER_BACKORDER, PACK_COMP_CUST_RESV, PACK_COMP_CUST_BACK, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, FIRST_RECEIVED, LAST_RECEIVED, QTY_RECEIVED, FIRST_SOLD, LAST_SOLD, QTY_SOLD, PRIMARY_SUPP, PRIMARY_CNTRY, AVERAGE_WEIGHT, FINISHER_AV_RETAIL, FINISHER_UNITS, PACK_COMP_NON_SELLABLE)
			values(LOG_MG || 'OLD', :old.ITEM, :old.ITEM_PARENT, :old.ITEM_GRANDPARENT, :old.LOC, :old.LOC_TYPE, :old.AV_COST, :old.UNIT_COST, :old.STOCK_ON_HAND, :old.SOH_UPDATE_DATETIME, :old.LAST_HIST_EXPORT_DATE, :old.IN_TRANSIT_QTY, :old.PACK_COMP_INTRAN, :old.PACK_COMP_SOH, :old.TSF_RESERVED_QTY, :old.PACK_COMP_RESV, :old.TSF_EXPECTED_QTY, :old.PACK_COMP_EXP, :old.RTV_QTY, :old.NON_SELLABLE_QTY, :old.CUSTOMER_RESV, :old.CUSTOMER_BACKORDER, :old.PACK_COMP_CUST_RESV, :old.PACK_COMP_CUST_BACK, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID, :old.FIRST_RECEIVED, :old.LAST_RECEIVED, :old.QTY_RECEIVED, :old.FIRST_SOLD, :old.LAST_SOLD, :old.QTY_SOLD, :old.PRIMARY_SUPP, :old.PRIMARY_CNTRY, :old.AVERAGE_WEIGHT, :old.FINISHER_AV_RETAIL, :old.FINISHER_UNITS, :old.PACK_COMP_NON_SELLABLE);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_ITEM_LOC_SOH_TRG ENABLE;
-- Next
-- TB_INV_STATUS_QTY
CREATE TABLE BTM_TEST_INV_STATUS_QTY AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM INV_STATUS_QTY TBS WHERE 1=0;
ALTER TABLE BTM_TEST_INV_STATUS_QTY  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_INV_STATUS_QTY_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON INV_STATUS_QTY
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_INV_STATUS_QTY(LOG_MG, LOC_TYPE, LOCATION, QTY, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, ITEM, INV_STATUS)
			values(LOG_MG || 'NEW', :new.LOC_TYPE, :new.LOCATION, :new.QTY, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID, :new.ITEM, :new.INV_STATUS);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_INV_STATUS_QTY(LOG_MG, LOC_TYPE, LOCATION, QTY, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, ITEM, INV_STATUS)
			values(LOG_MG || 'OLD', :old.LOC_TYPE, :old.LOCATION, :old.QTY, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID, :old.ITEM, :old.INV_STATUS);
		-- insert new
		INSERT INTO BTM_TEST_INV_STATUS_QTY(LOG_MG, LOC_TYPE, LOCATION, QTY, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, ITEM, INV_STATUS)
			values(LOG_MG || 'NEW', :new.LOC_TYPE, :new.LOCATION, :new.QTY, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID, :new.ITEM, :new.INV_STATUS);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_INV_STATUS_QTY(LOG_MG, LOC_TYPE, LOCATION, QTY, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, ITEM, INV_STATUS)
			values(LOG_MG || 'OLD', :old.LOC_TYPE, :old.LOCATION, :old.QTY, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID, :old.ITEM, :old.INV_STATUS);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_INV_STATUS_QTY_TRG ENABLE;
-- Next
-- TB_TSF_XFORM_DETAIL
CREATE TABLE BTM_TEST_TSF_XFORM_DETAIL AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM TSF_XFORM_DETAIL TBS WHERE 1=0;
ALTER TABLE BTM_TEST_TSF_XFORM_DETAIL  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_TSF_XFORM_DETAIL_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON TSF_XFORM_DETAIL
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_TSF_XFORM_DETAIL(LOG_MG, TSF_XFORM_DETAIL_ID, TSF_XFORM_ID, FROM_ITEM, FROM_QTY, TO_ITEM, TO_QTY, QTY_XFORMED, PUBLISH_IND)
			values(LOG_MG || 'NEW', :new.TSF_XFORM_DETAIL_ID, :new.TSF_XFORM_ID, :new.FROM_ITEM, :new.FROM_QTY, :new.TO_ITEM, :new.TO_QTY, :new.QTY_XFORMED, :new.PUBLISH_IND);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSF_XFORM_DETAIL(LOG_MG, TSF_XFORM_DETAIL_ID, TSF_XFORM_ID, FROM_ITEM, FROM_QTY, TO_ITEM, TO_QTY, QTY_XFORMED, PUBLISH_IND)
			values(LOG_MG || 'OLD', :old.TSF_XFORM_DETAIL_ID, :old.TSF_XFORM_ID, :old.FROM_ITEM, :old.FROM_QTY, :old.TO_ITEM, :old.TO_QTY, :old.QTY_XFORMED, :old.PUBLISH_IND);
		-- insert new
		INSERT INTO BTM_TEST_TSF_XFORM_DETAIL(LOG_MG, TSF_XFORM_DETAIL_ID, TSF_XFORM_ID, FROM_ITEM, FROM_QTY, TO_ITEM, TO_QTY, QTY_XFORMED, PUBLISH_IND)
			values(LOG_MG || 'NEW', :new.TSF_XFORM_DETAIL_ID, :new.TSF_XFORM_ID, :new.FROM_ITEM, :new.FROM_QTY, :new.TO_ITEM, :new.TO_QTY, :new.QTY_XFORMED, :new.PUBLISH_IND);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSF_XFORM_DETAIL(LOG_MG, TSF_XFORM_DETAIL_ID, TSF_XFORM_ID, FROM_ITEM, FROM_QTY, TO_ITEM, TO_QTY, QTY_XFORMED, PUBLISH_IND)
			values(LOG_MG || 'OLD', :old.TSF_XFORM_DETAIL_ID, :old.TSF_XFORM_ID, :old.FROM_ITEM, :old.FROM_QTY, :old.TO_ITEM, :old.TO_QTY, :old.QTY_XFORMED, :old.PUBLISH_IND);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_TSF_XFORM_DETAIL_TRG ENABLE;
-- Next
-- TB_TSF_ITEM_COST
CREATE TABLE BTM_TEST_TSF_ITEM_COST AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM TSF_ITEM_COST TBS WHERE 1=0;
ALTER TABLE BTM_TEST_TSF_ITEM_COST  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_TSF_ITEM_COST_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON TSF_ITEM_COST
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_TSF_ITEM_COST(LOG_MG, TSF_ITEM_COST_ID, TSF_NO, ITEM, TSF_PARENT_NO, TSF_QTY, TSF_AVG_PRICE, SHIPPED_QTY, XFORM_TO_ITEM, LEG_IND, ICT_LEG_IND)
			values(LOG_MG || 'NEW', :new.TSF_ITEM_COST_ID, :new.TSF_NO, :new.ITEM, :new.TSF_PARENT_NO, :new.TSF_QTY, :new.TSF_AVG_PRICE, :new.SHIPPED_QTY, :new.XFORM_TO_ITEM, :new.LEG_IND, :new.ICT_LEG_IND);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSF_ITEM_COST(LOG_MG, TSF_ITEM_COST_ID, TSF_NO, ITEM, TSF_PARENT_NO, TSF_QTY, TSF_AVG_PRICE, SHIPPED_QTY, XFORM_TO_ITEM, LEG_IND, ICT_LEG_IND)
			values(LOG_MG || 'OLD', :old.TSF_ITEM_COST_ID, :old.TSF_NO, :old.ITEM, :old.TSF_PARENT_NO, :old.TSF_QTY, :old.TSF_AVG_PRICE, :old.SHIPPED_QTY, :old.XFORM_TO_ITEM, :old.LEG_IND, :old.ICT_LEG_IND);
		-- insert new
		INSERT INTO BTM_TEST_TSF_ITEM_COST(LOG_MG, TSF_ITEM_COST_ID, TSF_NO, ITEM, TSF_PARENT_NO, TSF_QTY, TSF_AVG_PRICE, SHIPPED_QTY, XFORM_TO_ITEM, LEG_IND, ICT_LEG_IND)
			values(LOG_MG || 'NEW', :new.TSF_ITEM_COST_ID, :new.TSF_NO, :new.ITEM, :new.TSF_PARENT_NO, :new.TSF_QTY, :new.TSF_AVG_PRICE, :new.SHIPPED_QTY, :new.XFORM_TO_ITEM, :new.LEG_IND, :new.ICT_LEG_IND);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TSF_ITEM_COST(LOG_MG, TSF_ITEM_COST_ID, TSF_NO, ITEM, TSF_PARENT_NO, TSF_QTY, TSF_AVG_PRICE, SHIPPED_QTY, XFORM_TO_ITEM, LEG_IND, ICT_LEG_IND)
			values(LOG_MG || 'OLD', :old.TSF_ITEM_COST_ID, :old.TSF_NO, :old.ITEM, :old.TSF_PARENT_NO, :old.TSF_QTY, :old.TSF_AVG_PRICE, :old.SHIPPED_QTY, :old.XFORM_TO_ITEM, :old.LEG_IND, :old.ICT_LEG_IND);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_TSF_ITEM_COST_TRG ENABLE;
-- Next
-- TB_TRAN_DATA_A
CREATE TABLE BTM_TEST_TRAN_DATA_A AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM TRAN_DATA_A TBS WHERE 1=0;
ALTER TABLE BTM_TEST_TRAN_DATA_A  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_TRAN_DATA_A_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON TRAN_DATA_A
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_TRAN_DATA_A(LOG_MG, TOTAL_COST_EXCL_ELC, ITEM, DEPT, CLASS, SUBCLASS, PACK_IND, LOC_TYPE, LOCATION, TRAN_DATE, TRAN_CODE, ADJ_CODE, UNITS, TOTAL_COST, TOTAL_RETAIL, REF_NO_1, REF_NO_2, GL_REF_NO, OLD_UNIT_RETAIL, NEW_UNIT_RETAIL, PGM_NAME, SALES_TYPE, VAT_RATE, AV_COST, TIMESTAMP, REF_PACK_NO)
			values(LOG_MG || 'NEW', :new.TOTAL_COST_EXCL_ELC, :new.ITEM, :new.DEPT, :new.CLASS, :new.SUBCLASS, :new.PACK_IND, :new.LOC_TYPE, :new.LOCATION, :new.TRAN_DATE, :new.TRAN_CODE, :new.ADJ_CODE, :new.UNITS, :new.TOTAL_COST, :new.TOTAL_RETAIL, :new.REF_NO_1, :new.REF_NO_2, :new.GL_REF_NO, :new.OLD_UNIT_RETAIL, :new.NEW_UNIT_RETAIL, :new.PGM_NAME, :new.SALES_TYPE, :new.VAT_RATE, :new.AV_COST, :new.TIMESTAMP, :new.REF_PACK_NO);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TRAN_DATA_A(LOG_MG, TOTAL_COST_EXCL_ELC, ITEM, DEPT, CLASS, SUBCLASS, PACK_IND, LOC_TYPE, LOCATION, TRAN_DATE, TRAN_CODE, ADJ_CODE, UNITS, TOTAL_COST, TOTAL_RETAIL, REF_NO_1, REF_NO_2, GL_REF_NO, OLD_UNIT_RETAIL, NEW_UNIT_RETAIL, PGM_NAME, SALES_TYPE, VAT_RATE, AV_COST, TIMESTAMP, REF_PACK_NO)
			values(LOG_MG || 'OLD', :old.TOTAL_COST_EXCL_ELC, :old.ITEM, :old.DEPT, :old.CLASS, :old.SUBCLASS, :old.PACK_IND, :old.LOC_TYPE, :old.LOCATION, :old.TRAN_DATE, :old.TRAN_CODE, :old.ADJ_CODE, :old.UNITS, :old.TOTAL_COST, :old.TOTAL_RETAIL, :old.REF_NO_1, :old.REF_NO_2, :old.GL_REF_NO, :old.OLD_UNIT_RETAIL, :old.NEW_UNIT_RETAIL, :old.PGM_NAME, :old.SALES_TYPE, :old.VAT_RATE, :old.AV_COST, :old.TIMESTAMP, :old.REF_PACK_NO);
		-- insert new
		INSERT INTO BTM_TEST_TRAN_DATA_A(LOG_MG, TOTAL_COST_EXCL_ELC, ITEM, DEPT, CLASS, SUBCLASS, PACK_IND, LOC_TYPE, LOCATION, TRAN_DATE, TRAN_CODE, ADJ_CODE, UNITS, TOTAL_COST, TOTAL_RETAIL, REF_NO_1, REF_NO_2, GL_REF_NO, OLD_UNIT_RETAIL, NEW_UNIT_RETAIL, PGM_NAME, SALES_TYPE, VAT_RATE, AV_COST, TIMESTAMP, REF_PACK_NO)
			values(LOG_MG || 'NEW', :new.TOTAL_COST_EXCL_ELC, :new.ITEM, :new.DEPT, :new.CLASS, :new.SUBCLASS, :new.PACK_IND, :new.LOC_TYPE, :new.LOCATION, :new.TRAN_DATE, :new.TRAN_CODE, :new.ADJ_CODE, :new.UNITS, :new.TOTAL_COST, :new.TOTAL_RETAIL, :new.REF_NO_1, :new.REF_NO_2, :new.GL_REF_NO, :new.OLD_UNIT_RETAIL, :new.NEW_UNIT_RETAIL, :new.PGM_NAME, :new.SALES_TYPE, :new.VAT_RATE, :new.AV_COST, :new.TIMESTAMP, :new.REF_PACK_NO);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_TRAN_DATA_A(LOG_MG, TOTAL_COST_EXCL_ELC, ITEM, DEPT, CLASS, SUBCLASS, PACK_IND, LOC_TYPE, LOCATION, TRAN_DATE, TRAN_CODE, ADJ_CODE, UNITS, TOTAL_COST, TOTAL_RETAIL, REF_NO_1, REF_NO_2, GL_REF_NO, OLD_UNIT_RETAIL, NEW_UNIT_RETAIL, PGM_NAME, SALES_TYPE, VAT_RATE, AV_COST, TIMESTAMP, REF_PACK_NO)
			values(LOG_MG || 'OLD', :old.TOTAL_COST_EXCL_ELC, :old.ITEM, :old.DEPT, :old.CLASS, :old.SUBCLASS, :old.PACK_IND, :old.LOC_TYPE, :old.LOCATION, :old.TRAN_DATE, :old.TRAN_CODE, :old.ADJ_CODE, :old.UNITS, :old.TOTAL_COST, :old.TOTAL_RETAIL, :old.REF_NO_1, :old.REF_NO_2, :old.GL_REF_NO, :old.OLD_UNIT_RETAIL, :old.NEW_UNIT_RETAIL, :old.PGM_NAME, :old.SALES_TYPE, :old.VAT_RATE, :old.AV_COST, :old.TIMESTAMP, :old.REF_PACK_NO);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_TRAN_DATA_A_TRG ENABLE;
-- Next
-- TB_ITEM_LOC_HIST
CREATE TABLE BTM_TEST_ITEM_LOC_HIST AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM ITEM_LOC_HIST TBS WHERE 1=0;
ALTER TABLE BTM_TEST_ITEM_LOC_HIST  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_ITEM_LOC_HIST_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON ITEM_LOC_HIST
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_ITEM_LOC_HIST(LOG_MG, ITEM, LOC, LOC_TYPE, EOW_DATE, WEEK_454, MONTH_454, YEAR_454, SALES_TYPE, SALES_ISSUES, VALUE, GP, STOCK, RETAIL, AV_COST, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID)
			values(LOG_MG || 'NEW', :new.ITEM, :new.LOC, :new.LOC_TYPE, :new.EOW_DATE, :new.WEEK_454, :new.MONTH_454, :new.YEAR_454, :new.SALES_TYPE, :new.SALES_ISSUES, :new.VALUE, :new.GP, :new.STOCK, :new.RETAIL, :new.AV_COST, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ITEM_LOC_HIST(LOG_MG, ITEM, LOC, LOC_TYPE, EOW_DATE, WEEK_454, MONTH_454, YEAR_454, SALES_TYPE, SALES_ISSUES, VALUE, GP, STOCK, RETAIL, AV_COST, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID)
			values(LOG_MG || 'OLD', :old.ITEM, :old.LOC, :old.LOC_TYPE, :old.EOW_DATE, :old.WEEK_454, :old.MONTH_454, :old.YEAR_454, :old.SALES_TYPE, :old.SALES_ISSUES, :old.VALUE, :old.GP, :old.STOCK, :old.RETAIL, :old.AV_COST, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID);
		-- insert new
		INSERT INTO BTM_TEST_ITEM_LOC_HIST(LOG_MG, ITEM, LOC, LOC_TYPE, EOW_DATE, WEEK_454, MONTH_454, YEAR_454, SALES_TYPE, SALES_ISSUES, VALUE, GP, STOCK, RETAIL, AV_COST, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID)
			values(LOG_MG || 'NEW', :new.ITEM, :new.LOC, :new.LOC_TYPE, :new.EOW_DATE, :new.WEEK_454, :new.MONTH_454, :new.YEAR_454, :new.SALES_TYPE, :new.SALES_ISSUES, :new.VALUE, :new.GP, :new.STOCK, :new.RETAIL, :new.AV_COST, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ITEM_LOC_HIST(LOG_MG, ITEM, LOC, LOC_TYPE, EOW_DATE, WEEK_454, MONTH_454, YEAR_454, SALES_TYPE, SALES_ISSUES, VALUE, GP, STOCK, RETAIL, AV_COST, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID)
			values(LOG_MG || 'OLD', :old.ITEM, :old.LOC, :old.LOC_TYPE, :old.EOW_DATE, :old.WEEK_454, :old.MONTH_454, :old.YEAR_454, :old.SALES_TYPE, :old.SALES_ISSUES, :old.VALUE, :old.GP, :old.STOCK, :old.RETAIL, :old.AV_COST, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_ITEM_LOC_HIST_TRG ENABLE;
-- Next
-- TB_ITEM_LOC
CREATE TABLE BTM_TEST_ITEM_LOC AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM ITEM_LOC TBS WHERE 1=0;
ALTER TABLE BTM_TEST_ITEM_LOC  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_ITEM_LOC_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON ITEM_LOC
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_ITEM_LOC(LOG_MG, ITEM, LOC, ITEM_PARENT, ITEM_GRANDPARENT, LOC_TYPE, UNIT_RETAIL, REGULAR_UNIT_RETAIL, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, SELLING_UNIT_RETAIL, SELLING_UOM, PROMO_RETAIL, PROMO_SELLING_RETAIL, PROMO_SELLING_UOM, CLEAR_IND, TAXABLE_IND, LOCAL_ITEM_DESC, LOCAL_SHORT_DESC, TI, HI, STORE_ORD_MULT, STATUS, STATUS_UPDATE_DATE, DAILY_WASTE_PCT, MEAS_OF_EACH, MEAS_OF_PRICE, UOM_OF_PRICE, PRIMARY_VARIANT, PRIMARY_COST_PACK, PRIMARY_SUPP, PRIMARY_CNTRY, RECEIVE_AS_TYPE, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, INBOUND_HANDLING_DAYS, SOURCE_METHOD, SOURCE_WH, STORE_PRICE_IND, RPM_IND, UIN_TYPE, UIN_LABEL, CAPTURE_TIME, EXT_UIN_IND)
			values(LOG_MG || 'NEW', :new.ITEM, :new.LOC, :new.ITEM_PARENT, :new.ITEM_GRANDPARENT, :new.LOC_TYPE, :new.UNIT_RETAIL, :new.REGULAR_UNIT_RETAIL, :new.MULTI_UNITS, :new.MULTI_UNIT_RETAIL, :new.MULTI_SELLING_UOM, :new.SELLING_UNIT_RETAIL, :new.SELLING_UOM, :new.PROMO_RETAIL, :new.PROMO_SELLING_RETAIL, :new.PROMO_SELLING_UOM, :new.CLEAR_IND, :new.TAXABLE_IND, :new.LOCAL_ITEM_DESC, :new.LOCAL_SHORT_DESC, :new.TI, :new.HI, :new.STORE_ORD_MULT, :new.STATUS, :new.STATUS_UPDATE_DATE, :new.DAILY_WASTE_PCT, :new.MEAS_OF_EACH, :new.MEAS_OF_PRICE, :new.UOM_OF_PRICE, :new.PRIMARY_VARIANT, :new.PRIMARY_COST_PACK, :new.PRIMARY_SUPP, :new.PRIMARY_CNTRY, :new.RECEIVE_AS_TYPE, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID, :new.INBOUND_HANDLING_DAYS, :new.SOURCE_METHOD, :new.SOURCE_WH, :new.STORE_PRICE_IND, :new.RPM_IND, :new.UIN_TYPE, :new.UIN_LABEL, :new.CAPTURE_TIME, :new.EXT_UIN_IND);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ITEM_LOC(LOG_MG, ITEM, LOC, ITEM_PARENT, ITEM_GRANDPARENT, LOC_TYPE, UNIT_RETAIL, REGULAR_UNIT_RETAIL, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, SELLING_UNIT_RETAIL, SELLING_UOM, PROMO_RETAIL, PROMO_SELLING_RETAIL, PROMO_SELLING_UOM, CLEAR_IND, TAXABLE_IND, LOCAL_ITEM_DESC, LOCAL_SHORT_DESC, TI, HI, STORE_ORD_MULT, STATUS, STATUS_UPDATE_DATE, DAILY_WASTE_PCT, MEAS_OF_EACH, MEAS_OF_PRICE, UOM_OF_PRICE, PRIMARY_VARIANT, PRIMARY_COST_PACK, PRIMARY_SUPP, PRIMARY_CNTRY, RECEIVE_AS_TYPE, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, INBOUND_HANDLING_DAYS, SOURCE_METHOD, SOURCE_WH, STORE_PRICE_IND, RPM_IND, UIN_TYPE, UIN_LABEL, CAPTURE_TIME, EXT_UIN_IND)
			values(LOG_MG || 'OLD', :old.ITEM, :old.LOC, :old.ITEM_PARENT, :old.ITEM_GRANDPARENT, :old.LOC_TYPE, :old.UNIT_RETAIL, :old.REGULAR_UNIT_RETAIL, :old.MULTI_UNITS, :old.MULTI_UNIT_RETAIL, :old.MULTI_SELLING_UOM, :old.SELLING_UNIT_RETAIL, :old.SELLING_UOM, :old.PROMO_RETAIL, :old.PROMO_SELLING_RETAIL, :old.PROMO_SELLING_UOM, :old.CLEAR_IND, :old.TAXABLE_IND, :old.LOCAL_ITEM_DESC, :old.LOCAL_SHORT_DESC, :old.TI, :old.HI, :old.STORE_ORD_MULT, :old.STATUS, :old.STATUS_UPDATE_DATE, :old.DAILY_WASTE_PCT, :old.MEAS_OF_EACH, :old.MEAS_OF_PRICE, :old.UOM_OF_PRICE, :old.PRIMARY_VARIANT, :old.PRIMARY_COST_PACK, :old.PRIMARY_SUPP, :old.PRIMARY_CNTRY, :old.RECEIVE_AS_TYPE, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID, :old.INBOUND_HANDLING_DAYS, :old.SOURCE_METHOD, :old.SOURCE_WH, :old.STORE_PRICE_IND, :old.RPM_IND, :old.UIN_TYPE, :old.UIN_LABEL, :old.CAPTURE_TIME, :old.EXT_UIN_IND);
		-- insert new
		INSERT INTO BTM_TEST_ITEM_LOC(LOG_MG, ITEM, LOC, ITEM_PARENT, ITEM_GRANDPARENT, LOC_TYPE, UNIT_RETAIL, REGULAR_UNIT_RETAIL, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, SELLING_UNIT_RETAIL, SELLING_UOM, PROMO_RETAIL, PROMO_SELLING_RETAIL, PROMO_SELLING_UOM, CLEAR_IND, TAXABLE_IND, LOCAL_ITEM_DESC, LOCAL_SHORT_DESC, TI, HI, STORE_ORD_MULT, STATUS, STATUS_UPDATE_DATE, DAILY_WASTE_PCT, MEAS_OF_EACH, MEAS_OF_PRICE, UOM_OF_PRICE, PRIMARY_VARIANT, PRIMARY_COST_PACK, PRIMARY_SUPP, PRIMARY_CNTRY, RECEIVE_AS_TYPE, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, INBOUND_HANDLING_DAYS, SOURCE_METHOD, SOURCE_WH, STORE_PRICE_IND, RPM_IND, UIN_TYPE, UIN_LABEL, CAPTURE_TIME, EXT_UIN_IND)
			values(LOG_MG || 'NEW', :new.ITEM, :new.LOC, :new.ITEM_PARENT, :new.ITEM_GRANDPARENT, :new.LOC_TYPE, :new.UNIT_RETAIL, :new.REGULAR_UNIT_RETAIL, :new.MULTI_UNITS, :new.MULTI_UNIT_RETAIL, :new.MULTI_SELLING_UOM, :new.SELLING_UNIT_RETAIL, :new.SELLING_UOM, :new.PROMO_RETAIL, :new.PROMO_SELLING_RETAIL, :new.PROMO_SELLING_UOM, :new.CLEAR_IND, :new.TAXABLE_IND, :new.LOCAL_ITEM_DESC, :new.LOCAL_SHORT_DESC, :new.TI, :new.HI, :new.STORE_ORD_MULT, :new.STATUS, :new.STATUS_UPDATE_DATE, :new.DAILY_WASTE_PCT, :new.MEAS_OF_EACH, :new.MEAS_OF_PRICE, :new.UOM_OF_PRICE, :new.PRIMARY_VARIANT, :new.PRIMARY_COST_PACK, :new.PRIMARY_SUPP, :new.PRIMARY_CNTRY, :new.RECEIVE_AS_TYPE, :new.CREATE_DATETIME, :new.LAST_UPDATE_DATETIME, :new.LAST_UPDATE_ID, :new.INBOUND_HANDLING_DAYS, :new.SOURCE_METHOD, :new.SOURCE_WH, :new.STORE_PRICE_IND, :new.RPM_IND, :new.UIN_TYPE, :new.UIN_LABEL, :new.CAPTURE_TIME, :new.EXT_UIN_IND);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_ITEM_LOC(LOG_MG, ITEM, LOC, ITEM_PARENT, ITEM_GRANDPARENT, LOC_TYPE, UNIT_RETAIL, REGULAR_UNIT_RETAIL, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, SELLING_UNIT_RETAIL, SELLING_UOM, PROMO_RETAIL, PROMO_SELLING_RETAIL, PROMO_SELLING_UOM, CLEAR_IND, TAXABLE_IND, LOCAL_ITEM_DESC, LOCAL_SHORT_DESC, TI, HI, STORE_ORD_MULT, STATUS, STATUS_UPDATE_DATE, DAILY_WASTE_PCT, MEAS_OF_EACH, MEAS_OF_PRICE, UOM_OF_PRICE, PRIMARY_VARIANT, PRIMARY_COST_PACK, PRIMARY_SUPP, PRIMARY_CNTRY, RECEIVE_AS_TYPE, CREATE_DATETIME, LAST_UPDATE_DATETIME, LAST_UPDATE_ID, INBOUND_HANDLING_DAYS, SOURCE_METHOD, SOURCE_WH, STORE_PRICE_IND, RPM_IND, UIN_TYPE, UIN_LABEL, CAPTURE_TIME, EXT_UIN_IND)
			values(LOG_MG || 'OLD', :old.ITEM, :old.LOC, :old.ITEM_PARENT, :old.ITEM_GRANDPARENT, :old.LOC_TYPE, :old.UNIT_RETAIL, :old.REGULAR_UNIT_RETAIL, :old.MULTI_UNITS, :old.MULTI_UNIT_RETAIL, :old.MULTI_SELLING_UOM, :old.SELLING_UNIT_RETAIL, :old.SELLING_UOM, :old.PROMO_RETAIL, :old.PROMO_SELLING_RETAIL, :old.PROMO_SELLING_UOM, :old.CLEAR_IND, :old.TAXABLE_IND, :old.LOCAL_ITEM_DESC, :old.LOCAL_SHORT_DESC, :old.TI, :old.HI, :old.STORE_ORD_MULT, :old.STATUS, :old.STATUS_UPDATE_DATE, :old.DAILY_WASTE_PCT, :old.MEAS_OF_EACH, :old.MEAS_OF_PRICE, :old.UOM_OF_PRICE, :old.PRIMARY_VARIANT, :old.PRIMARY_COST_PACK, :old.PRIMARY_SUPP, :old.PRIMARY_CNTRY, :old.RECEIVE_AS_TYPE, :old.CREATE_DATETIME, :old.LAST_UPDATE_DATETIME, :old.LAST_UPDATE_ID, :old.INBOUND_HANDLING_DAYS, :old.SOURCE_METHOD, :old.SOURCE_WH, :old.STORE_PRICE_IND, :old.RPM_IND, :old.UIN_TYPE, :old.UIN_LABEL, :old.CAPTURE_TIME, :old.EXT_UIN_IND);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_ITEM_LOC_TRG ENABLE;
-- Next
-- TB_PRICE_HIST
CREATE TABLE BTM_TEST_PRICE_HIST AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM PRICE_HIST TBS WHERE 1=0;
ALTER TABLE BTM_TEST_PRICE_HIST  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_PRICE_HIST_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON PRICE_HIST
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_PRICE_HIST(LOG_MG, TRAN_TYPE, REASON, EVENT, ITEM, LOC, LOC_TYPE, UNIT_COST, UNIT_RETAIL, SELLING_UNIT_RETAIL, SELLING_UOM, ACTION_DATE, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, POST_DATE)
			values(LOG_MG || 'NEW', :new.TRAN_TYPE, :new.REASON, :new.EVENT, :new.ITEM, :new.LOC, :new.LOC_TYPE, :new.UNIT_COST, :new.UNIT_RETAIL, :new.SELLING_UNIT_RETAIL, :new.SELLING_UOM, :new.ACTION_DATE, :new.MULTI_UNITS, :new.MULTI_UNIT_RETAIL, :new.MULTI_SELLING_UOM, :new.POST_DATE);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_PRICE_HIST(LOG_MG, TRAN_TYPE, REASON, EVENT, ITEM, LOC, LOC_TYPE, UNIT_COST, UNIT_RETAIL, SELLING_UNIT_RETAIL, SELLING_UOM, ACTION_DATE, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, POST_DATE)
			values(LOG_MG || 'OLD', :old.TRAN_TYPE, :old.REASON, :old.EVENT, :old.ITEM, :old.LOC, :old.LOC_TYPE, :old.UNIT_COST, :old.UNIT_RETAIL, :old.SELLING_UNIT_RETAIL, :old.SELLING_UOM, :old.ACTION_DATE, :old.MULTI_UNITS, :old.MULTI_UNIT_RETAIL, :old.MULTI_SELLING_UOM, :old.POST_DATE);
		-- insert new
		INSERT INTO BTM_TEST_PRICE_HIST(LOG_MG, TRAN_TYPE, REASON, EVENT, ITEM, LOC, LOC_TYPE, UNIT_COST, UNIT_RETAIL, SELLING_UNIT_RETAIL, SELLING_UOM, ACTION_DATE, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, POST_DATE)
			values(LOG_MG || 'NEW', :new.TRAN_TYPE, :new.REASON, :new.EVENT, :new.ITEM, :new.LOC, :new.LOC_TYPE, :new.UNIT_COST, :new.UNIT_RETAIL, :new.SELLING_UNIT_RETAIL, :new.SELLING_UOM, :new.ACTION_DATE, :new.MULTI_UNITS, :new.MULTI_UNIT_RETAIL, :new.MULTI_SELLING_UOM, :new.POST_DATE);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_PRICE_HIST(LOG_MG, TRAN_TYPE, REASON, EVENT, ITEM, LOC, LOC_TYPE, UNIT_COST, UNIT_RETAIL, SELLING_UNIT_RETAIL, SELLING_UOM, ACTION_DATE, MULTI_UNITS, MULTI_UNIT_RETAIL, MULTI_SELLING_UOM, POST_DATE)
			values(LOG_MG || 'OLD', :old.TRAN_TYPE, :old.REASON, :old.EVENT, :old.ITEM, :old.LOC, :old.LOC_TYPE, :old.UNIT_COST, :old.UNIT_RETAIL, :old.SELLING_UNIT_RETAIL, :old.SELLING_UOM, :old.ACTION_DATE, :old.MULTI_UNITS, :old.MULTI_UNIT_RETAIL, :old.MULTI_SELLING_UOM, :old.POST_DATE);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_PRICE_HIST_TRG ENABLE;
-- Next
-- TB_SHIPITEM_INV_FLOW
CREATE TABLE BTM_TEST_SHIPITEM_INV_FLOW AS SELECT 'LOG_MG' LOG_MG, TBS.* FROM SHIPITEM_INV_FLOW TBS WHERE 1=0;
ALTER TABLE BTM_TEST_SHIPITEM_INV_FLOW  MODIFY (LOG_MG CHAR(48 BYTE));

create or replace TRIGGER BTM_TEST_SHIPITEM_INV_FLOW_TRG
	AFTER DELETE OR INSERT OR UPDATE
	ON SHIPITEM_INV_FLOW
	FOR EACH ROW
DECLARE
	LOG_MG varchar2(48) := null;
--PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
	LOG_MG := TO_CHAR(SYSTIMESTAMP,'YY-MM-DD hh24:mi:ss.FF') || ' - ';
	
	IF INSERTING  THEN
		LOG_MG := LOG_MG || 'INSERTING' || ' - ';
		-- insert new
		INSERT INTO BTM_TEST_SHIPITEM_INV_FLOW(LOG_MG, SHIPMENT, SEQ_NO, ITEM, FROM_LOC, TO_LOC, FROM_LOC_TYPE, TO_LOC_TYPE, TSF_NO, TSF_SEQ_NO, TSF_QTY, RECEIVED_QTY, DIST_PCT)
			values(LOG_MG || 'NEW', :new.SHIPMENT, :new.SEQ_NO, :new.ITEM, :new.FROM_LOC, :new.TO_LOC, :new.FROM_LOC_TYPE, :new.TO_LOC_TYPE, :new.TSF_NO, :new.TSF_SEQ_NO, :new.TSF_QTY, :new.RECEIVED_QTY, :new.DIST_PCT);
	ELSIF UPDATING THEN
		LOG_MG := LOG_MG || 'UPDATING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_SHIPITEM_INV_FLOW(LOG_MG, SHIPMENT, SEQ_NO, ITEM, FROM_LOC, TO_LOC, FROM_LOC_TYPE, TO_LOC_TYPE, TSF_NO, TSF_SEQ_NO, TSF_QTY, RECEIVED_QTY, DIST_PCT)
			values(LOG_MG || 'OLD', :old.SHIPMENT, :old.SEQ_NO, :old.ITEM, :old.FROM_LOC, :old.TO_LOC, :old.FROM_LOC_TYPE, :old.TO_LOC_TYPE, :old.TSF_NO, :old.TSF_SEQ_NO, :old.TSF_QTY, :old.RECEIVED_QTY, :old.DIST_PCT);
		-- insert new
		INSERT INTO BTM_TEST_SHIPITEM_INV_FLOW(LOG_MG, SHIPMENT, SEQ_NO, ITEM, FROM_LOC, TO_LOC, FROM_LOC_TYPE, TO_LOC_TYPE, TSF_NO, TSF_SEQ_NO, TSF_QTY, RECEIVED_QTY, DIST_PCT)
			values(LOG_MG || 'NEW', :new.SHIPMENT, :new.SEQ_NO, :new.ITEM, :new.FROM_LOC, :new.TO_LOC, :new.FROM_LOC_TYPE, :new.TO_LOC_TYPE, :new.TSF_NO, :new.TSF_SEQ_NO, :new.TSF_QTY, :new.RECEIVED_QTY, :new.DIST_PCT);
	ELSIF DELETING THEN
		LOG_MG := LOG_MG || 'DELETING' || ' - ';
		-- insert old
		INSERT INTO BTM_TEST_SHIPITEM_INV_FLOW(LOG_MG, SHIPMENT, SEQ_NO, ITEM, FROM_LOC, TO_LOC, FROM_LOC_TYPE, TO_LOC_TYPE, TSF_NO, TSF_SEQ_NO, TSF_QTY, RECEIVED_QTY, DIST_PCT)
			values(LOG_MG || 'OLD', :old.SHIPMENT, :old.SEQ_NO, :old.ITEM, :old.FROM_LOC, :old.TO_LOC, :old.FROM_LOC_TYPE, :old.TO_LOC_TYPE, :old.TSF_NO, :old.TSF_SEQ_NO, :old.TSF_QTY, :old.RECEIVED_QTY, :old.DIST_PCT);
	END IF;
END;
/
ALTER TRIGGER BTM_TEST_SHIPITEM_INV_FLOW_TRG ENABLE;
-- Next
